let tipsEl=document.querySelector(".tips")
let regEmail=/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
let regPassword=/^(?=.*[a-zA-Z])(?=.*[0-9])[A-Za-z0-9,._!@#$^&*]{8,20}$/
let regName=/^[\w\u4E00-\u9FA5]{4,20}$/
let getCode=document.querySelector(".getcode")
let backEl=document.querySelector("header  div")
let time=null

backEl.addEventListener("click",function(){
    console.log("1");
    window.history.go(-1)
})

//判断邮箱格式，如果不正确提示邮箱格式有问题
function judgeEmail(){
    if(regEmail.test(uEmailInp.value)==false){
        tipsEl.textContent="邮箱错误"
        tipsEl.classList.add("active")
        return false
    } else{return true}
}
//判断密码格式，如果不正确提示密码格式有问题
function judgePassWord(){
    if(regPassword.test(passwordInp.value)==false){
        tipsEl.textContent="密码格式错误"
        tipsEl.classList.add("active")
        return false
    } else{return true}
}
// 判断用户名正不正确
function judgeName(){
    if(regName.test(uEmailInp.value)==false){
        tipsEl.textContent="用户名错误，特殊符号只能包含字母，数字，下划线，减号"
        tipsEl.classList.add("active")
        return false
    } else{return true}
}
//判断验证码正不正确，如果不正确提示验证码错误
function judgeCode(msg){
    tipsEl.textContent=msg
    tipsEl.classList.add("active")
    console.log("11");
}

//移出tips
function judgeRemove(){
    tipsEl.classList.remove("active")
    clearInterval(time)
}
// 倒计时2s后让tips消失
function judgeRemoveTime(){
    time = setInterval(
        judgeRemove, 1000
    )
}
//获取验证码倒计时
function Countdown(text, seconds, ref, cb) {
    let secondsRemaining = seconds
    const timer = setInterval(() => {
        ref.textContent = `(${secondsRemaining}) 秒`
        --secondsRemaining
        if (secondsRemaining === 0) {
            clearInterval(timer)
            ref.textContent = text
            cb && cb()
        }
    }, 1000)
}
